package module.location;

public class CoordinatesHandler
{
	private static CoordinatesHandler singleton;
	private java.util.ArrayList<CoordinatesUpdateListener> listeners = new java.util.ArrayList<CoordinatesUpdateListener>();
	
	private CoordinatesHandler()
	{}
	
	public static CoordinatesHandler getCoordinatesHandler()
	{
		if (singleton == null)
			singleton = new CoordinatesHandler();
		return singleton;
	}
	
	public void addCoordinatesListener(CoordinatesUpdateListener listener)
	{
		listeners.add(listener);
	}
	
	public void removeCoordinatesListener(CoordinatesUpdateListener listener)
	{
		listeners.remove(listener);
	}
	
	public void fireCoordinatesEvent(Coordinates newCoordinates)
	{
		for (CoordinatesUpdateListener c : listeners)
		{
			c.onNewCoordinates(newCoordinates);
		}
	}
}
